#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 1500005;
int n,k,mxde,ans;
vector<int>e[N];
int a[N];
bool flag;
void dfs(int u,int fa,int cnt,int len)
{
    len++;
    cnt += a[u];
    if(len == k)
    {
        //cout<<u<<" "<<cnt<<" "<<len;
        flag &= (cnt == 1);
        return ;
    }
    for(auto v:e[u]) if(v != fa) dfs(v,u,cnt,len);
}
void check()
{
    flag = 1;
    for(int i = 1;i <= n;i++)
    {
        dfs(i,0,0,0);
        if(flag == 0) return ;
    }
    ans++;
}
void dfs(int u)
{
    if(u == n+1)
    {
        check();
        return ;
    }
    a[u] = 1;
    dfs(u+1);
    a[u] = 0;
    dfs(u+1);
    return ;
}
int main()
{
    freopen("life.in","r",stdin);
    freopen("life.out","w",stdout);
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n>>k;
    for(int i = 1;i < n;i++)
    {
        int u,v;cin>>u>>v;
        e[u].pb(v),e[v].pb(u);
    }
    for(int i = 1;i <= n;i++) mxde = max(mxde,int(e[i].size()));
    if(mxde == 2)
    {
        cout<<"YES\n";
        cout<<k<<"\n";
        return 0;
    }
    dfs(1);
    if(ans) cout<<"YES\n";
    else cout<<"NO\n";
    cout<<ans<<"\n";
    return 0;
}